package com.tiny.model;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;

public class Permission extends Model<Permission>{

	private static final long serialVersionUID = 5721481570867001054L;

	public static final Permission dao = new Permission();
	
	public Integer getId() {
		return this.getInt("id");
	}
	
	public String getKey(){
		return this.getStr("permission");
	}
	
	public Integer getParentId(){
		return this.getInt("parent_id");
	}
	
	public String getDescription(){
		return this.getStr("description");
	}
	
	public List<Permission> getAllPermission(){
		return Permission.dao.find(" select * from permission ");
	}
	
	public Permission get(List<Permission> permissions, int id) {
        for(Permission permission:permissions){
            if(permission.getId().intValue()==id){
                return permission;
            }
        }
        return null;
    }
}
